package config

import (
	"fmt"
	"github.com/spf13/viper"
)

var (
	Config AppConfig
	err    error
)

type AppConfig struct {
	Mysql
}
type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

func Init() {

	viper.SetConfigFile("./config.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
		return
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic("配置文件连接失败")
		return
	} else {
		fmt.Println("配置文件连接成功")
	}

}
